{template nheader.html}
<link href="{THEME_PATH}admin/global/css/add.css?t={time()}.{rand(10000,9999999)}" rel="stylesheet"  />
<script src="{THEME_PATH}admin/global/scripts/add.js?t={time()}.{rand(10000,9999999)}"></script>
<link href="{THEME_PATH}admin/global/css/form_default.css?t={time()}.{rand(10000,9999999)}" rel="stylesheet"  />
<script>
    function uploadFile(){
        //alert('123');
        var myform = new FormData();
        myform.append('img',$('#load_img')[0].files[0]);
        // console.log(s);return false;
        $.ajax({
            url: "admin.php?c=banner&m=uploadImg",
            type: "POST",
            data: myform,
            contentType: false,
            processData: false,
            success: function (data) {
                console.log(data);
                var obj = JSON.parse(data);
                if(obj.status == 1){
                    $('input[name="upload_img"]').val(obj.img_url);
                    $(".image-data").html(obj.img_url);
                    $('.update-class-pic').css('cssText','background-image:url('+obj.img_url+');');
                    $(".update-word-add").fadeOut();
                }
                else{
                    $(".image-data").text("格式错误，请重新选择");
                    $(".update-word-add").fadeIn();
                }
            },
            error:function(data){
                console.log(data);
            }
        });
    }
</script>
<div class="step-display">
    <div class="active">
        <span>1</span>
        <span>选择课程分类</span>
    </div>
    <div>
        <span>2</span>
        <span>填写课程信息</span>
    </div>
    <div>
        <span>3</span>
        <span>课程发布成功</span>
    </div>
</div>
<form class="form-horizontal" action="" method="post" id="myform" name="myform" style="margin-top:30px;margin-bottom: 70px;">
    <input type="hidden" name="upload_img" value=""/>
    <input type="hidden" name="course"/>
    <div class="portlet light bordered">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject font-green bold uppercase">
                    <span style="font-family: FontAwesome;"></span>
                    <!-- {$name} -->
                    <span class="title">
                        {fc_lang('选择课程分类')}
                    </span>
                </span>
            </div>
        </div>
        <div class="portlet-body">
            <div class="portlet-body form">
                <div class="form-body">

                    <div class="form-page-1">

                        <div class="page-recently-select">
                            <label>{fc_lang('您最近使用的课程分类')}：</label>
                            <select>
                                <option value="">请选择</option>
                                <!--<option value ="1V4/初一/语文">1V4/初一/语文</option>-->
                                <!--<option value ="1V4/一年级/英语">1V4/一年级/英语</option>-->
                            </select>
                        </div>

                        <div class="page-class-my-select">

                            <div class="type">
                                <div class="title">{fc_lang('选择课程类型')}</div>
                                <div class="content">
                                    <div>1V4</div>
                                    <div>1V1</div>
                                    <div>专题课</div>
                                    <div>录播课</div>
                                </div>
                            </div>

                            <div class="stage">
                                <div class="title">{fc_lang('选择适用年级')}</div>
                                <div class="content">
                                    {loop $stages $key $vals}
                                    <div>{$vals}</div>
                                    {/loop}
                                </div>
                            </div>

                            <div class="subject">
                                <div class="title">{fc_lang('选择学科')}</div>
                                <div class="content">
                                    {loop $subjects $k $sub}
                                    <div>{$sub}</div>
                                    {/loop}
                                </div>
                            </div>

                        </div>
                    </div>

                    <div class="form-page-2">

                        <div class="form-group class-course-sorts">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('课程分类')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list"></div>
                                <div class="course-edit">编辑</div>
                            </div>
                        </div>

                        <div class="form-group record-class-teacher">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('授课老师')}：
                            </label>
                            <div class="col-md-9">
                                <label>{dr_field_input('name','Text', $field['name']['setting'], $data['name'])}</label>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('课程标题')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>{dr_field_input('title', 'Text', $field['title']['setting'], $data['title'])}</label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('副标题')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>{dr_field_input('aux_title', 'Text', $field['aux_title']['setting'], $data['aux_title'])}</label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('关键词')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>
                                        <input class="form-control" type="text" name="sel_keywords" id="dr_keywords">
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('课程售价')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>
                                        <input class="form-control" type="text" name="sel_price" id="dr_sel_price">
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('市场价')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>
                                        <input class="form-control" type="text" name="del_price" id="dr_del_price">
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('权重排序(值越大,排序越靠前)')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>
                                        <input class="form-control" type="text" name="del_sort" id="dr_del_sort">
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('上传课程封面')}：
                            </label>
                            <div class="col-md-9">
                                <label class="update-class-pic">
                                    <span class="image-data">未选择任何档案</span>
                                    <input type="file" id="load_img" name="img"onchange ="uploadFile()"/>
                                    <span class="update-word-add">
                                        <p>+</p>
                                        <p>上传图片</p>
                                    </span>
                                </label>
                                <p>只能上传jpg/png格式文件，文件不能超过100kb</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">
                                <span class="le_required">*</span>
                                {fc_lang('课程详细信息编辑')}：
                            </label>
                            <div class="col-md-9">
                                <div class="radio-list">
                                    <label>{dr_field_input('content', 'TextArea',$field['content']['remark'], $data['content'])}</label>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>

    <div class="myfooter">
        <div class="row">
            <div class="portlet-body form">
                <div class="form-body">
                    <div class="form-actions">
                        <div class="row">
                            <div class="col-md-12 text-center">
                                <a class="btn green next-wright-class">{fc_lang('下一步，填写课程信息')}</a>
                                <button type="submit" class="btn green only-save" name="subtype" value="0">{fc_lang('仅保存')}</button>
                                <button type="submit" class="btn green next-record-class" href="/admin.php?c=publics&m=addvideo">{fc_lang('下一步')}</button>
                                <button type="submit" class="btn green release-post" name="subtype" value="1">{fc_lang('发布并上架')}</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</form>
<script>
    $(function () {
        //仅保存
        $(".only-save").click(function () {
            var title = $("#dr_title").val(),
                aux_title = $("#dr_aux_title").val(),
                sel_price = $("#dr_sel_price").val(),
                del_price = $("#dr_del_price"),
                load_img = $("#load_img").val();
                cont = $("#dr_content").val();
                if(!title){
                    alert('课程标题不能为空');
                    return false;
                }
                if(!aux_title){
                    alert('副标题不能为空');
                    return false;
                }
                if(!sel_price){
                    alert("课程售价不能为空");
                    return false;
                }
                if(!del_price){
                    alert("市场价不能为空");
                    return false;
                }
                if(!load_img){
                    alert("上传图片不能为空");
                    return false;
                }
                if(!cont){
                    alert("课程内容不能为空");
                    return false;
                }
            return true;
        });
        // 保存和上架
        $(".release-post").click(function () {
            var title = $("#dr_title").val(),
                aux_title = $("#dr_aux_title").val(),
                sel_price = $("#dr_sel_price").val(),
                del_price = $("#dr_del_price"),
                load_img = $("#load_img").val();
            cont = $("#dr_content").val();
            if(!title){
                alert('课程标题不能为空');
                return false;
            }
            if(!aux_title){
                alert('副标题不能为空');
                return false;
            }
            if(!sel_price){
                alert("课程售价不能为空");
                return false;
            }
            if(!del_price){
                alert("市场价不能为空");
                return false;
            }
            if(!load_img){
                alert("上传图片不能为空");
                return false;
            }
            if(!cont){
                alert("课程内容不能为空");
                return false;
            }
            return true;
        });
        //上传录播视频
        $(".next-record-class").click(function () {
            var title = $("#dr_title").val(),
                name = $("#dr_name").val(),
                aux_title = $("#dr_aux_title").val(),
                sel_price = $("#dr_sel_price").val(),
                del_price = $("#dr_del_price"),
                load_img = $("#load_img").val(),
                cont = $("#dr_content").val();
            if(!name){
                alert('授课老师不能为空');
                return false;
            }
            if(!title){
                alert('课程标题不能为空');
                return false;
            }
            if(!aux_title){
                alert('副标题不能为空');
                return false;
            }
            if(!sel_price){
                alert("课程售价不能为空");
                return false;
            }
            if(!del_price){
                alert("市场价不能为空");
                return false;
            }
            if(!load_img){
                alert("上传图片不能为空");
                return false;
            }
            if(!cont){
                alert("课程内容不能为空");
                return false;
            }
            return true;
        });

    });
</script>

{template nfooter.html}